import Vue from 'vue'
import Vuex from 'vuex'

import { apiGetInfo } from '@/api/au.js'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: ''
  },
  mutations: {
    setUserInfo (state, payload) {
      state.userInfo = payload
    }
  },
  actions: {
    // 封装共同修改用户信息之后重新获取用户详情的方法
    async setUserInfo (context) {
      const res = await apiGetInfo()
      context.commit('setUserInfo', res.data)
    }
  },
  modules: {}
})
